package com.wosiliujing.learning.social.controller;

import com.wosiliujing.learning.entity.UserInfoDTO;
import com.wosiliujing.learning.annotation.Inner;
import com.wosiliujing.learning.social.service.SysSocialDetailsService;
import com.wosiliujing.learning.util.RestResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 * 社交登陆controller
 * @author 刘靖
 * @date 2019-09-24 9:30
 */
@RestController
@AllArgsConstructor
@Slf4j
@RequestMapping("/social")
public class SysSocialDetailsController {

    private final SysSocialDetailsService sysSocialDetailsService;

    /***
     * 社交登陆用户信息获取
     * @author 刘靖
     * @date 2019/9/24 9:40
     * @param type 社交类型
     * @param code  身份标识
     * @return 用户信息
     */
    @Inner(false)
    @GetMapping("/info/{type}/{code}")
    public RestResult<UserInfoDTO> socialLogin(@PathVariable("type") String type, @PathVariable("code") String code){
        UserInfoDTO userInfo = sysSocialDetailsService.getUserInfo(type,code);
        return RestResult.data(userInfo);
    }


}
